package com.yst.suivi.data.pointage;

import javax.ejb.CreateException;
import javax.ejb.EntityBean;

import com.yst.suivi.data.AbstractEntityBean;
import com.yst.suivi.data.activities.Activity;
import com.yst.suivi.data.user.User;
import com.yst.suivi.status.StatusConstants;

/**
 * @author stolf
 * @ejb.bean name="Pointage" type="CMP" cmp-version="2.x" schema="pointage"
 *           local-jndi-name="PointageBean" view-type="local" primkey-field =
 *           "id" reentrant = "True"
 * @ejb.home generate="local"
 * @ejb.persistence table-name = "pointage"
 * @jboss.entity-command name = "key-generator"
 * @jboss.read-ahead eager-load-group = "most" strategy = "on-load"
 *                   page-size="25"
 * @jboss.load-group name="most"
 * @ejb.interface local-extends = "javax.ejb.EJBLocalObject"
 * @ejb.finder signature="java.util.Collection findAll()" query="SELECT
 *             OBJECT(g) FROM pointage AS g"
 * @ejb.finder signature="com.yst.suivi.data.pointage.Pointage
 *             findByDate(java.lang.Integer jour, java.lang.Integer mois,
 *             java.lang.Integer annee, java.lang.Integer pos,
 *             com.yst.suivi.data.user.User usr)" query="SELECT OBJECT(g) FROM
 *             pointage AS g WHERE g.jour=?1 and g.mois=?2 and g.annee=?3 and
 *             g.tempsPos=?4 and g.user=?5"
 * @ejb.finder signature="com.yst.suivi.data.pointage.Pointage
 *             findByDateActUser(java.lang.Integer jour, java.lang.Integer mois,
 *             java.lang.Integer annee, com.yst.suivi.data.activities.Activity
 *             act, com.yst.suivi.data.user.User usr)" query="SELECT OBJECT(g)
 *             FROM pointage AS g WHERE g.jour=?1 and g.mois=?2 and g.annee=?3
 *             and g.activity=?4 and g.user=?5"
 * @ejb.finder signature="java.util.Collection
 *             findByActUser(com.yst.suivi.data.activities.Activity act,
 *             com.yst.suivi.data.user.User usr)" query="SELECT OBJECT(g) FROM
 *             pointage AS g WHERE g.activity=?1 and g.user=?2"
 * @ejb.finder signature="java.util.Collection
 *             findByAct(com.yst.suivi.data.activities.Activity act)"
 *             query="SELECT OBJECT(g) FROM pointage AS g WHERE g.activity=?1"
 * @ejb.finder signature="java.util.Collection findByDate(java.lang.Integer
 *             jour, java.lang.Integer mois, java.lang.Integer annee,
 *             com.yst.suivi.data.user.User usr)" query="SELECT OBJECT(g) FROM
 *             pointage AS g WHERE g.jour=?1 and g.mois=?2 and g.annee=?3 and
 *             g.user=?4"
 * @ejb.finder signature="java.util.Collection findByDate(java.lang.Integer
 *             mois, java.lang.Integer annee, com.yst.suivi.data.user.User usr)"
 *             query="SELECT OBJECT(g) FROM pointage AS g WHERE g.mois=?1 and
 *             g.annee=?2 and g.user=?3"
 * @ejb.finder signature="java.util.Collection findBy(java.lang.Integer annee)"
 *             query="SELECT OBJECT(g) FROM pointage AS g WHERE g.annee=?1"
 */
public abstract class PointageBean extends AbstractEntityBean implements EntityBean
{
	/**
	 * @return
	 * @throws CreateException
	 * @ejb.create-method view-type = "local"
	 */
	public String ejbCreate() throws CreateException
	{
		setStatus(StatusConstants.IN_PROGRESS);
		return null;
	}

	public void ejbPostCreate()
	{
		// by default nothing to do
	}

	/**
	 * Return the primary key of the object
	 * 
	 * @ejb.interface-method view-type = "local"
	 * @ejb.persistence
	 * @jboss.jdbc-type type = "VARCHAR"
	 * @jboss.sql-type type = "VARCHAR(255)"
	 */
	public abstract String getId();

	/**
	 * Fix the primary key of the object. The method should be used only by the
	 * container
	 * 
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setId(String id);

	/**
	 * Return the day of the object
	 * 
	 * @ejb.interface-method view-type = "local"
	 * @ejb.persistence
	 * @jboss.load-group name="most"
	 */
	public abstract Integer getJour();

	/**
	 * Fix the day of the user.
	 * 
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setJour(Integer jour);

	/**
	 * Return the day of the object
	 * 
	 * @ejb.interface-method view-type = "local"
	 * @ejb.persistence
	 * @jboss.load-group name="most"
	 */
	public abstract Integer getMois();

	/**
	 * Fix the day of the user.
	 * 
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setMois(Integer mois);

	/**
	 * Return the day of the object
	 * 
	 * @ejb.interface-method view-type = "local"
	 * @ejb.persistence
	 * @jboss.load-group name="most"
	 */
	public abstract Integer getAnnee();

	/**
	 * Fix the day of the user.
	 * 
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setAnnee(Integer annee);

	/**
	 * Return the position of the emargement in the day. The position depends on
	 * the sub division of working day 8 hours, 2 half day, ...
	 * 
	 * @ejb.interface-method view-type = "local"
	 * @ejb.persistence column-name="dayWorkload"
	 * @jboss.load-group name="most"
	 */
	public abstract Integer getTempsPos();

	/**
	 * Etat du pointage. Selon l'etat, elle peut etre plus ou moins modifiee
	 * 
	 * @ejb.interface-method view-type = "local"
	 * @ejb.persistence
	 * @jboss.load-group name="most"
	 */
	public abstract int getStatus();

	/**
	 * Positionne l'etat du pointage
	 * 
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setStatus(int status);

	/**
	 * Fix the day of the user.
	 * 
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setTempsPos(Integer nom);

	/**
	 * La methode lie le Pointage a une activite
	 * 
	 * @return
	 * @ejb.relation name="Pointage-Activity" role-name = "PointageActivity"
	 *               target-role-name = "PointageActivityRole" target-multiple =
	 *               "yes" target-ejb="Activity"
	 * @jboss.relation related-pk-field = "id" fk-constraint = "true" fk-column =
	 *                 "actId"
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract Activity getActivity();

	/**
	 * La methode lie le Pointage a une activite
	 * 
	 * @param plf
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setActivity(Activity plf);

	/**
	 * Retourne la liste des utilisateurs affectes au projet
	 * 
	 * @return Collection
	 * @ejb.relation name="Pointage-User" role-name = "PointageUser"
	 *               target-role-name = "PointageUserRole" target-multiple =
	 *               "yes" target-ejb="User"
	 * @jboss.relation related-pk-field = "id" fk-constraint = "true" fk-column =
	 *                 "userId"
	 * @ejb.interface-method view-type = "local"
	 * @return Collection
	 */
	public abstract User getUser();

	/**
	 * Positionne la liste de tous les utilisateurs qui doivent travailler sur
	 * le projet. La collection doit contenir des objets User.
	 * 
	 * @param user
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setUser(User user);

	/**
	 * Return the weekk of the year
	 * 
	 * @return
	 * @ejb.interface-method view-type = "local"
	 * @ejb.persistence
	 * @ejb.persistence column-name="weeknumber"
	 * @jboss.load-group name="most"
	 */
	public abstract Integer getWeekNumber();

	/**
	 * Fix the week of the year
	 * 
	 * @param week
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setWeekNumber(Integer week);
}
